asm
  ld sp,$8FEF
  end asm

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"

dim eee as uinteger at $8810
dim seed as uinteger at $8812
dim ee1 as uinteger at $8814
dim ee2 as uinteger at $8816
dim ee3 as uinteger at $8818
dim ee4 as ubyte at $881A
dim eex as ubyte at $881C
dim eey as ubyte at $881E

sub champbasputchar(tx1 as uinteger,ty1 as uinteger,tch1 as ubyte,tat1 as ubyte)
  poke ($8000+(ty1*32)+tx1),tch1
  poke ($8400+(ty1*32)+tx1),tat1
  end sub

seed=0

for ee3=0 to 31
  for ee4=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    champbasputchar(ee4,ee3,seed band 3,ee2)
    next:next

for ee3=0 to 15
  for ee4=0 to 15
    champbasputchar(ee4+15,ee3+13,ee3*16+ee4,0)
    next:next

eee=0

eex=8:eey=8
do

  champbasputchar(1,3,48+((int(eee/10000)) mod 10),0)
  champbasputchar(2,3,48+((int(eee/1000)) mod 10),0)
  champbasputchar(3,3,48+((int(eee/100)) mod 10),0)
  champbasputchar(4,3,48+((int(eee/10)) mod 10),0)
  champbasputchar(5,3,48+(eee mod 10),0)

  ee1=peek($A000) bxor $FF
  champbasputchar(3,5,48+((int(ee1/100)) mod 10),0)
  champbasputchar(4,5,48+((int(ee1/10)) mod 10),0)
  champbasputchar(5,5,48+(ee1 mod 10),0)

  eex=eex+((ee1 band 64)/64)-((ee1 band 32)/32)
  eey=eey+((ee1 band 128)/128)-((ee1 band 16)/16)

  ee1=peek($A040) bxor $FF
  champbasputchar(3,6,48+((int(ee1/100)) mod 10),0)
  champbasputchar(4,6,48+((int(ee1/10)) mod 10),0)
  champbasputchar(5,6,48+(ee1 mod 10),0)
  ee1=peek($A080) bxor $FF
  champbasputchar(3,7,48+((int(ee1/100)) mod 10),0)
  champbasputchar(4,7,48+((int(ee1/10)) mod 10),0)
  champbasputchar(5,7,48+(ee1 mod 10),0)
  ee1=peek($A0C0) bxor $FF
  champbasputchar(3,8,48+((int(ee1/100)) mod 10),0)
  champbasputchar(4,8,48+((int(ee1/10)) mod 10),0)
  champbasputchar(5,8,48+(ee1 mod 10),0)

  champbasputchar(eex,eey,eee,0)

  eee=eee+1
  loop




for eee=$0000 to $07FF
  ee2=seed:seed=smsrnd(seed)
  ee2=seed:seed=smsrnd(seed)
  poke eee+$8000,seed
  poke eee+$8400,seed
  pacmandelay(5000)
  next






do

for eee=$8000 to $83FF '-videoram (chr)
  seed=smsrnd(seed)
  poke eee,seed
  next
for eee=$8400 to $87FF '-videoram (attr)
  seed=smsrnd(seed)
  poke eee,seed
  next
for eee=$8FF0 to $8FFF '-spriteram
  seed=smsrnd(seed)
  poke eee,seed
  next
for eee=$A060 to $A06F '-spriteram2
  seed=smsrnd(seed)
  poke eee,seed
  next

loop

do:loop

'----------------------------------


'static ADDRESS_MAP_START( champbas_main_map, AS_PROGRAM, 8, champbas_state )
'AM_RANGE(0x0000, 0x5fff) AM_ROM
'AM_RANGE(0x6000, 0x63ff) AM_RAM AM_SHARE("share1")
'AM_RANGE(0x7000, 0x7001) AM_DEVWRITE("aysnd", ay8910_device, data_address_w)
'AM_RANGE(0x7800, 0x7fff) AM_ROM // champbb2 only
'AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(champbas_bg_videoram_w) AM_SHARE("bg_videoram")
'AM_RANGE(0x8800, 0x8fef) AM_RAM
'AM_RANGE(0x8ff0, 0x8fff) AM_RAM AM_SHARE("spriteram")

'AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1")
'AM_RANGE(0xa040, 0xa040) AM_READ_PORT("P2")
'AM_RANGE(0xa080, 0xa080) AM_READ_PORT("DSW")
'AM_RANGE(0xa0c0, 0xa0c0) AM_READ_PORT("SYSTEM")

'AM_RANGE(0xa000, 0xa000) AM_WRITE(irq_enable_w)
'AM_RANGE(0xa001, 0xa001) AM_WRITENOP    // !WORK board output (no use?)
'AM_RANGE(0xa002, 0xa002) AM_WRITE(champbas_gfxbank_w)
'AM_RANGE(0xa003, 0xa003) AM_WRITE(champbas_flipscreen_w)
'AM_RANGE(0xa004, 0xa004) AM_WRITE(champbas_palette_bank_w)
'AM_RANGE(0xa005, 0xa005) AM_WRITENOP    // n.c.
'AM_RANGE(0xa006, 0xa006) AM_WRITE(champbas_mcu_halt_w)  // MCU not present/not used in champbas
'AM_RANGE(0xa007, 0xa007) AM_WRITE(champbas_mcu_switch_w)    // MCU not present/not used in champbas

'AM_RANGE(0xa060, 0xa06f) AM_RAM AM_SHARE("spriteram_2")
'AM_RANGE(0xa080, 0xa080) AM_WRITE(soundlatch_byte_w)
'/*  AM_RANGE(0xa0a0, 0xa0a0)    ???? */
'AM_RANGE(0xa0c0, 0xa0c0) AM_WRITE(champbas_watchdog_reset_w)

'/* champbja only */
'AM_RANGE(0x6800, 0x68ff) AM_READ(champbja_alt_protection_r)
'ADDRESS_MAP_END






'- static ADDRESS_MAP_START( shisen_map, AS_PROGRAM, 8, shisen_state )
'- AM_RANGE(0x0000, 0x7fff) AM_ROM
'- AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
'- AM_RANGE(0xc800, 0xcaff) AM_RAM_WRITE(paletteram_w) AM_SHARE("paletteram")
'- AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(videoram_w) AM_SHARE("videoram")
'- AM_RANGE(0xe000, 0xffff) AM_RAM



'
'dim ex0 as uinteger at $9110
'dim ey0 as uinteger at $9112
'
'dim ej0 as uinteger at $9114
'dim ej1 as uinteger at $9116
'
'sub pingpongputsprite(tlayer as ubyte,tx as ubyte,ty as ubyte,tid as ubyte,tclut as ubyte):
'  poke $9006+((tlayer band 15)*4),tx  '- x sprite 0
'  poke $9004+((tlayer band 15)*4),ty bxor 255  '- y sprite 0
'  poke $9005+((tlayer band 15)*4),tid          '- shape sprite 0
'  poke $9003+((tlayer band 15)*4),tclut        '- clut? sprite 0
'  end sub
'
'function test1(t1 as uinteger,t2 as uinteger,t3 as uinteger,t4 as uinteger)  as uinteger
'  end function
'
'sub zpoke(t1 as uinteger,t2 as ubyte)
'  poke t1,t2
'  end sub
'
'
'pingpongputsprite(0,21,10,4,3)
'pingpongputsprite(1,21,30,4,3)
'pingpongputsprite(2,21,50,4,3)
'pingpongputsprite(3,21,70,4,3)
'pingpongputsprite(4,21,90,4,3)
'pingpongputsprite(5,21,110,4,3)
'pingpongputsprite(6,21,130,4,3)
'pingpongputsprite(7,21,150,4,3)
'
'seed=0
'
'for ee2=64 to 1023-64
'  for ee3=1 to 100
'    poke $8400+ee2,$01
'    next:next
'
'ee4=0
'for ee2=3 to 3+15
'  for ee3=15 to 15+15
'    poke $8400+ee3+(ee2*32),ee4
'    ee4=ee4+1
'    next:next
'
'ee4=0
'for ee2=20 to 20+7
'  for ee3=15 to 15+15
'    poke $8400+ee3+(ee2*32),ee4 band 3
'    poke $8000+ee3+(ee2*32),int(ee4/4)
'    ee4=ee4+1
'    next:next
'
'
'
'
'for ee2=4 to 7
'  for ee3=2 to 5
'    poke $8400+ee3+(ee2*32),code("X")
'    next
'    next
'
'test1(377,2445,63888,2342)
'
'eee=$4207
'i=code("Q")
'poke eee,i
'eee=eee+1
'i=code("T")
'poke eee,i
'
'seed=0
'for eee=$4400 to $47FF
'  seed=smsrnd(seed)
'  poke eee,seed
'  next
'
'ex0=80:ey0=176
'
'eee=0
'ecsp=0:ecsq=0
'
'
'do
'poke $A600,255 '- watchdog? - it seems to work! thanks, Jim Bagley!!!!
'
'ej0=peek($A800) bxor $ff
'ej1=peek($A880) bxor $ff
'
'poke ($8400+(10*32)+6) bxor %0000001111100000,ej0
'poke ($8400+(10*32)+7) bxor %0000001111100000,ej1
'
'poke ($8400+(12*32)+8) bxor %0000001111100000,48+(ex0 mod 10)
'poke ($8400+(12*32)+7) bxor %0000001111100000,48+((int(ex0/10)) mod 10)
'poke ($8400+(12*32)+6) bxor %0000001111100000,48+((int(ex0/100)) mod 10)
'
'poke ($8400+(13*32)+8) bxor %0000001111100000,48+(ey0 mod 10)
'poke ($8400+(13*32)+7) bxor %0000001111100000,48+((int(ey0/10)) mod 10)
'poke ($8400+(13*32)+6) bxor %0000001111100000,48+((int(ey0/100)) mod 10)
'
'poke ($8400+(14*32)+8) bxor %0000001111100000,48+(eee mod 10)
'poke ($8400+(14*32)+7) bxor %0000001111100000,48+((int(eee/10)) mod 10)
'poke ($8400+(14*32)+6) bxor %0000001111100000,48+((int(eee/100)) mod 10)
'poke ($8400+(14*32)+5) bxor %0000001111100000,48+((int(eee/1000)) mod 10)
'poke ($8400+(14*32)+4) bxor %0000001111100000,48+((int(eee/10000)) mod 10)
'
'poke ($8400+(15*32)+8) bxor %0000001111100000,48+(ej0 mod 10)
'poke ($8400+(15*32)+7) bxor %0000001111100000,48+((int(ej0/10)) mod 10)
'poke ($8400+(15*32)+6) bxor %0000001111100000,48+((int(ej0/100)) mod 10)
'
'poke ($8400+(16*32)+8) bxor %0000001111100000,48+(ej1 mod 10)
'poke ($8400+(16*32)+7) bxor %0000001111100000,48+((int(ej1/10)) mod 10)
'poke ($8400+(16*32)+6) bxor %0000001111100000,48+((int(ej1/100)) mod 10)
'
'poke ($8400+(17*32)+8) bxor %0000001111100000,48+(ecsp mod 10)
'
'if (ej1 band 64)<>0 then: ex0=ex0+1:end if
'if (ej1 band 32)<>0 then: ex0=ex0-1:end if
'if (ej1 band 4)<>0 then: ey0=ey0+1:end if
'if (ej1 band 2)<>0 then: ey0=ey0-1:end if
'
'if (ej1 band 15)<>0 then: ecsq=ecsq+1:end if
'ecsp=(int(ecsq/4))mod 8
'
'ee3=int(eee/4)
'
'pingpongputsprite( 0,ex0   ,ey0   ,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 1,ex0+16,ey0   ,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 2,ex0+32,ey0   ,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 3,ex0+48,ey0   ,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 4,ex0   ,ey0+16,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 5,ex0+16,ey0+16,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 6,ex0+32,ey0+16,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 7,ex0+48,ey0+16,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 8,ex0   ,ey0+32,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 9,ex0+16,ey0+32,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(10,ex0+32,ey0+32,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(11,ex0+48,ey0+32,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(12,ex0   ,ey0+48,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(13,ex0+16,ey0+48,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(14,ex0+32,ey0+48,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(15,ex0+48,ey0+48,4,3)  '- layer,x,y,id,clut
'
'
'eee=eee+1
'loop
'
''-------------------------------------------------------------------------------
'
'text01:
'asm
'  defb "HELLO WORLD!!!!!"
'  end asm
'
''-------------------------------------------------------------------------------
'
'
